﻿namespace AnyOffice.DAL
{
    using AnyOffice.Components;
    using AnyOffice.Model;
    using log4net;
    using Microsoft.ApplicationBlocks.Data;
    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Reflection;
    using System.Web;

    public class SmsDao
    {
        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public bool BizSend(SqlConnection conn, SmsData data, bool isSms, bool isMobile)
        {
            if (isSms || isMobile)
            {
                string commandText = "DECLARE @RemindPriv nvarchar(4000) SELECT @RemindPriv = CAST([RemindPriv] AS nvarchar(4000)) FROM [dbo].[Mobile_Priv] IF @IsSms = 1 INSERT [dbo].[Sms] ( [FromId], [ToId], [Type], [Content], [SendTime], [RelateId], [Url] ) SELECT @FromId, [UserId], @Type, @Content, @SendTime, @RelateId, @Url FROM [dbo].[Users] WHERE ";
                if (!((data.ToIdListIsNull && data.ToDeptListIsNull) && data.ToPrivListIsNull))
                {
                    commandText = commandText + "\t[UserId] <> @FromId AND ";
                }
                commandText = commandText + "([UserId] = ISNULL(@ToId,'') OR (CHARINDEX(',' + [UserId] + ',',',' + ISNULL(@ToIdList,'') + ',') >0) OR (ISNULL(@ToDeptList,'') = 'ALL_DEPT') OR (CHARINDEX(',' + CAST([DeptId] AS nvarchar(20)) + ',',',' + ISNULL(@ToDeptList,'') + ',') > 0) OR (CHARINDEX(',' + CAST([PrivId] AS nvarchar(20)) + ',',',' + ISNULL(@ToPrivList,'') + ',') > 0) )IF @IsMobile = 1 INSERT [dbo].[OutBox] ( [V1], [username], [Mbno], [Msg], [SendTime],Report,ComPort ) SELECT @FromId, [UserId], [Mobile], @Content, @SendTime,0,0 FROM [dbo].[Users] WHERE ([UserId] <> @FromId OR @Type = 5) and ( [UserId] = ISNULL(@ToId,'') OR (CHARINDEX(',' + [UserId] + ',',',' + @ToIdList + ',') >0) OR (ISNULL(@ToDeptList,'') = 'ALL_DEPT') OR (CHARINDEX(',' + CAST([DeptId] AS nvarchar(20)) + ',',',' + ISNULL(@ToDeptList,'') + ',') > 0) OR (CHARINDEX(',' + CAST([PrivId] AS nvarchar(20)) + ',',',' + ISNULL(@ToPrivList,'') + ',') > 0) ) AND (LEN(ISNULL([Mobile],'')) > 10) ";
                SqlParameter[] commandParameters = new SqlParameter[12];
                commandParameters[0] = new SqlParameter("@Type", SqlDbType.Int);
                commandParameters[0].Value = data.Type;
                commandParameters[1] = new SqlParameter("@FromId", SqlDbType.NVarChar, 20);
                commandParameters[1].Value = data.FromId;
                commandParameters[2] = new SqlParameter("@ToId", SqlDbType.NVarChar, 20);
                if (data.ToIdIsNull)
                {
                    commandParameters[2].Value = DBNull.Value;
                }
                else
                {
                    commandParameters[2].Value = data.ToId;
                }
                commandParameters[3] = new SqlParameter("@ToIdList", SqlDbType.NVarChar, 0xfa0);
                if (data.ToIdListIsNull)
                {
                    commandParameters[3].Value = DBNull.Value;
                }
                else
                {
                    commandParameters[3].Value = data.ToIdList;
                }
                commandParameters[4] = new SqlParameter("@ToDeptList", SqlDbType.NVarChar, 0x7d0);
                if (data.ToDeptListIsNull)
                {
                    commandParameters[4].Value = DBNull.Value;
                }
                else
                {
                    commandParameters[4].Value = data.ToDeptList;
                }
                commandParameters[5] = new SqlParameter("@ToPrivList", SqlDbType.NVarChar, 0x7d0);
                if (data.ToPrivListIsNull)
                {
                    commandParameters[5].Value = DBNull.Value;
                }
                else
                {
                    commandParameters[5].Value = data.ToPrivList;
                }
                commandParameters[6] = new SqlParameter("@Content", SqlDbType.NText);
                commandParameters[6].Value = data.Content;
                commandParameters[7] = new SqlParameter("@SendTime", SqlDbType.DateTime);
                commandParameters[7].Value = data.SendTime;
                commandParameters[8] = new SqlParameter("@RelateId", SqlDbType.Int);
                commandParameters[8].Value = data.RelateId;
                commandParameters[9] = new SqlParameter("@Url", SqlDbType.NText);
                if (data.UrlIsNull)
                {
                    commandParameters[9].Value = DBNull.Value;
                }
                else
                {
                    commandParameters[9].Value = data.Url;
                }
                commandParameters[10] = new SqlParameter("@IsSms", SqlDbType.Bit);
                commandParameters[10].Value = isSms;
                commandParameters[11] = new SqlParameter("@IsMobile", SqlDbType.Bit);
                commandParameters[11].Value = isMobile;
                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters);
                if (!isSms)
                {
                    return true;
                }
                ConfigManager manager = new ConfigManager();
                if (manager.RtxEnabled)
                {
                    try
                    {
                        Type type = Assembly.LoadFrom(HttpContext.Current.Server.MapPath("/bin/RTX.dll")).GetType("RTX.RtxSdk", true);
                        object obj2 = Activator.CreateInstance(type);
                        MethodInfo method = type.GetMethod("SendNotify");
                        string toIdList = data.ToIdIsNull ? "" : data.ToId;
                        if (!data.ToIdListIsNull)
                        {
                            if (toIdList == string.Empty)
                            {
                                toIdList = data.ToIdList;
                            }
                            else
                            {
                                toIdList = toIdList + "," + data.ToIdList;
                            }
                        }
                        UserCache cache = new UserCache();
                        string str3 = cache.UserName + "：" + data.Content;
                        object[] parameters = new object[] { toIdList, data.ToDeptListIsNull ? "" : data.ToDeptList, data.ToPrivListIsNull ? "" : data.ToPrivList, "OA提醒", str3 };
                        method.Invoke(obj2, parameters);
                    }
                    catch (Exception exception)
                    {
                        if (log.IsErrorEnabled)
                        {
                            log.Error("RTX", exception);
                        }
                    }
                }
            }
            return true;
        }

        public bool BizUpdate(SqlConnection conn, SmsData data, bool isSms, bool isMobile)
        {
            if (isSms || isMobile)
            {
                string commandText = "DECLARE @RemindPriv nvarchar(4000) SELECT @RemindPriv = CAST([RemindPriv] AS nvarchar) FROM [dbo].[Mobile_Priv] IF @IsSms = 1 IF (@RelateId <> 0) AND EXISTS(SELECT SmsId FROM Sms WHERE (Type = @Type) AND (RelateId = @RelateId)) UPDATE [dbo].[Sms] SET [Content] = @Content, [SendTime] = @SendTime, [RemindFlag] = 1 WHERE [Type] = @Type AND [RelateId] = @RelateId ELSE INSERT [dbo].[Sms] ( [FromId], [ToId], [Type], [Content], [SendTime], [RelateId], [Url] ) VALUES ( @FromId, @ToId, @Type, @Content, @SendTime, @RelateId, @Url ) IF @IsMobile = 1 INSERT dbo.Mobile ( [FromId], [ToId], [Phone], [Content], [SendTime] ) SELECT @FromId, [UserId], [Mobile], @Content, @SendTime FROM [dbo].[Users] WHERE [UserId] = @ToId AND LEN(ISNULL([Mobile],'')) >= 11";
                SqlParameter[] commandParameters = new SqlParameter[9];
                commandParameters[0] = new SqlParameter("@Type", SqlDbType.Int);
                commandParameters[0].Value = data.Type;
                commandParameters[1] = new SqlParameter("@FromId", SqlDbType.NVarChar, 20);
                commandParameters[1].Value = data.FromId;
                commandParameters[2] = new SqlParameter("@ToId", SqlDbType.NVarChar, 20);
                commandParameters[2].Value = data.ToId;
                commandParameters[3] = new SqlParameter("@Content", SqlDbType.NText);
                commandParameters[3].Value = data.Content;
                commandParameters[4] = new SqlParameter("@SendTime", SqlDbType.DateTime);
                commandParameters[4].Value = data.SendTime;
                commandParameters[5] = new SqlParameter("@RelateId", SqlDbType.Int);
                commandParameters[5].Value = data.RelateId;
                commandParameters[6] = new SqlParameter("@Url", SqlDbType.NText);
                if (data.UrlIsNull)
                {
                    commandParameters[6].Value = DBNull.Value;
                }
                else
                {
                    commandParameters[6].Value = data.Url;
                }
                commandParameters[7] = new SqlParameter("@IsSms", SqlDbType.Bit);
                commandParameters[7].Value = isSms;
                commandParameters[8] = new SqlParameter("@IsMobile", SqlDbType.Bit);
                commandParameters[8].Value = isMobile;
                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters);
            }
            return true;
        }

        public void CancelRemind(SqlConnection conn, int smsId, string userId)
        {
            string commandText = "UPDATE [dbo].[Sms] SET [RemindFlag] = 0 WHERE [SmsId] = @SmsId AND [ToId] = @UserId AND [RemindFlag] = 1 AND [SendTime] < GETDATE()";
            SqlParameter[] commandParameters = new SqlParameter[2];
            commandParameters[0] = new SqlParameter("@SmsId", SqlDbType.Int);
            commandParameters[0].Value = smsId;
            commandParameters[1] = new SqlParameter("@UserId", SqlDbType.NVarChar, 20);
            commandParameters[1].Value = userId;
            SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters);
        }

        public bool Delete(SqlConnection conn, int smsId, string userId)
        {
            string commandText = "DELETE FROM [dbo].[Sms] WHERE [SmsId] = @SmsId AND ( [FromId] = @UserId OR [ToId] = @UserId )";
            SqlParameter[] commandParameters = new SqlParameter[2];
            commandParameters[0] = new SqlParameter("@SmsId", SqlDbType.Int);
            commandParameters[0].Value = smsId;
            commandParameters[1] = new SqlParameter("@UserId", SqlDbType.NVarChar, 20);
            commandParameters[1].Value = userId;
            SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters);
            return true;
        }

        public void DeleteAll(SqlConnection conn, string userId, DeleteType delType)
        {
            string commandText = "IF @DelType =1 DELETE FROM [dbo].[Sms] WHERE [Sms].[ToId] = @UserId AND [SendTime] < GETDATE() ELSE DELETE FROM [dbo].[Sms] WHERE [Sms].[FromId] = @UserId AND [SendTime] < GETDATE()";
            SqlParameter[] commandParameters = new SqlParameter[2];
            commandParameters[0] = new SqlParameter("@UserId", SqlDbType.NVarChar, 20);
            commandParameters[0].Value = userId;
            commandParameters[1] = new SqlParameter("@DelType", SqlDbType.Int);
            commandParameters[1].Value = (int) delType;
            SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters);
        }

        public static bool IsMobile(SmsType type)
        {
            ConfigManager manager = new ConfigManager();
            string str = "," + manager.MobileTypePriv + ",";
            int num = (int) type;
            return (str.IndexOf("," + num.ToString() + ",") >= 0);
        }

        public static bool IsMobile(int type)
        {
            ConfigManager manager = new ConfigManager();
            return (("," + manager.MobileTypePriv + ",").IndexOf("," + type.ToString() + ",") >= 0);
        }

        public void ReadAll(SqlConnection conn, string userId)
        {
            string commandText = "UPDATE [dbo].[Sms] SET [RemindFlag] = 0 WHERE [Sms].[ToId] = @UserId AND [RemindFlag] = 1 AND [SendTime] < GETDATE()";
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@UserId", SqlDbType.NVarChar, 20) };
            commandParameters[0].Value = userId;
            SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters);
        }

        public DataTable Reveive(SqlConnection conn, int pagesize, int pageindex, bool docount, string userId)
        {
            string commandText = "IF(@docount=1) SELECT COUNT([Sms].[SmsId]) FROM [dbo].[Sms], [dbo].[Users], [dbo].[Sys_Code] WHERE [Sms].[ToId] = @UserId AND [Sms].[FromId] =[Users].[UserId] AND [SendTime] < GETDATE() AND CAST([Sms].[Type] AS nvarchar) = [Sys_Code].[CodeNo] AND [Sys_Code].[CodeFlag] = 'SMS_REMIND' ELSE BEGIN DECLARE @IndexTable TABLE(ID int identity(1,1),PK int) DECLARE @PageLowerBound int DECLARE @PageUpperBound int SET @PageLowerBound=(@pageindex-1)*@pagesize SET @PageUpperBound=@PageLowerBound+@pagesize SET rowcount @PageUpperBound INSERT INTO @IndexTable(PK) SELECT [Sms].[SmsId] FROM [dbo].[Sms], [dbo].[Users], [dbo].[Sys_Code] WHERE [Sms].[ToId] = @UserId AND [Sms].[FromId] =[Users].[UserId] AND [SendTime] < GETDATE() AND CAST([Sms].[Type] AS nvarchar) = [Sys_Code].[CodeNo] AND [Sys_Code].[CodeFlag] = 'SMS_REMIND' ORDER BY [Sms].[SendTime] DESC, [Sms].[SmsId] DESC SELECT [Sms].[SmsId], [Sms].[FromId], [Sms].[ToId], [Sms].[Type], [Sms].[Content], [Sms].[SendTime], [Sms].[RemindFlag], [Users].[UserName], [Users].[Avatar], [Sys_Code].[CodeName], @pageindex AS pageindex FROM [dbo].[Sms], [dbo].[Users], [dbo].[Sys_Code], @IndexTable t WHERE [Sms].[FromId] =[Users].[UserId] AND CAST([Sms].[Type] AS nvarchar) = [Sys_Code].[CodeNo] AND [Sys_Code].[CodeFlag] = 'SMS_REMIND' AND [Sms].[SmsId] = t.PK AND t.ID>@PageLowerBound AND t.ID<=@PageUpperBound ORDER BY [Sms].[SendTime] DESC, [Sms].[SmsId] DESC END";
            SqlParameter[] commandParameters = new SqlParameter[4];
            commandParameters[0] = new SqlParameter("@pagesize", SqlDbType.Int);
            commandParameters[0].Value = pagesize;
            commandParameters[1] = new SqlParameter("@pageindex", SqlDbType.Int);
            commandParameters[1].Value = pageindex;
            commandParameters[2] = new SqlParameter("@docount", SqlDbType.Bit);
            commandParameters[2].Value = docount;
            commandParameters[3] = new SqlParameter("@UserId", SqlDbType.NVarChar, 20);
            commandParameters[3].Value = userId;
            DataSet set = SqlHelper.ExecuteDataset(conn, CommandType.Text, commandText, commandParameters);
            set.Tables[0].TableName = "Sms";
            return set.Tables[0];
        }

        public DataTable Send(SqlConnection conn, int pagesize, int pageindex, bool docount, string userId)
        {
            string commandText = "IF(@docount=1) SELECT COUNT([Sms].[SmsId]) FROM [dbo].[Sms], [dbo].[Users], [dbo].[Sys_Code] WHERE [Sms].[FromId] = @UserId AND [Sms].[ToId] =[Users].[UserId] AND [SendTime] < GETDATE() AND CAST([Sms].[Type] AS nvarchar) = [Sys_Code].[CodeNo] AND [Sys_Code].[CodeFlag] = 'SMS_REMIND' ELSE BEGIN DECLARE @IndexTable TABLE(ID int identity(1,1),PK int) DECLARE @PageLowerBound int DECLARE @PageUpperBound int SET @PageLowerBound=(@pageindex-1)*@pagesize SET @PageUpperBound=@PageLowerBound+@pagesize SET rowcount @PageUpperBound INSERT INTO @IndexTable(PK) SELECT [Sms].[SmsId] FROM [dbo].[Sms], [dbo].[Users], [dbo].[Sys_Code] WHERE [Sms].[FromId] = @UserId AND [Sms].[ToId] =[Users].[UserId] AND [SendTime] < GETDATE() AND CAST([Sms].[Type] AS nvarchar) = [Sys_Code].[CodeNo] AND [Sys_Code].[CodeFlag] = 'SMS_REMIND' ORDER BY [Sms].[SendTime] DESC, [Sms].[SmsId] DESC SELECT [Sms].[SmsId], [Sms].[FromId], [Sms].[ToId], [Sms].[Type], [Sms].[Content], [Sms].[SendTime], [Sms].[RemindFlag], [Users].[UserName], [Users].[Avatar], [Sys_Code].[CodeName], @pageindex AS pageindex FROM [dbo].[Sms], [dbo].[Users], [dbo].[Sys_Code], @IndexTable t WHERE [Sms].[ToId] =[Users].[UserId] AND CAST([Sms].[Type] AS nvarchar) = [Sys_Code].[CodeNo] AND [Sys_Code].[CodeFlag] = 'SMS_REMIND' AND [Sms].[SmsId] = t.PK AND t.ID>@PageLowerBound AND t.ID<=@PageUpperBound ORDER BY [Sms].[SendTime] DESC, [Sms].[SmsId] DESC END";
            SqlParameter[] commandParameters = new SqlParameter[4];
            commandParameters[0] = new SqlParameter("@pagesize", SqlDbType.Int);
            commandParameters[0].Value = pagesize;
            commandParameters[1] = new SqlParameter("@pageindex", SqlDbType.Int);
            commandParameters[1].Value = pageindex;
            commandParameters[2] = new SqlParameter("@docount", SqlDbType.Bit);
            commandParameters[2].Value = docount;
            commandParameters[3] = new SqlParameter("@UserId", SqlDbType.NVarChar, 20);
            commandParameters[3].Value = userId;
            DataSet set = SqlHelper.ExecuteDataset(conn, CommandType.Text, commandText, commandParameters);
            set.Tables[0].TableName = "Sms";
            return set.Tables[0];
        }

        public void SmsBoxDelete(SqlConnection conn, string userId)
        {
            string commandText = "DELETE [dbo].[Sms] FROM ( SELECT TOP 5 [SmsId] FROM [dbo].[Sms] WHERE [ToId] = @UserId ORDER BY [SendTime] DESC, [SmsId] DESC ) AS TopSms WHERE [Sms].[SmsId] = TopSms.[SmsId]";
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@UserId", SqlDbType.NVarChar, 20) };
            commandParameters[0].Value = userId;
            SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters);
        }

        public DataTable SmsBoxSelect(SqlConnection conn, string userId)
        {
            string commandText = "SELECT [Sms].*, [Users].[UserName], [Users].[Avatar], [Department].[DeptName], [Sys_Code].[CodeName], [Sys_Code].[FuncCode] FROM [dbo].[Sms], [dbo].[Users], [dbo].[Sys_Code], [dbo].[Department] WHERE [Sms].[ToId] = @UserId AND [Sms].[FromId] =[Users].[UserId] AND [Users].[DeptId] = [Department].[DeptId] AND CAST([Sms].[Type] AS nvarchar) = [Sys_Code].[CodeNo] AND [Sys_Code].[CodeFlag] = 'SMS_REMIND' AND [Sms].[SmsId] IN ( SELECT TOP 5 [SmsId] FROM [dbo].[Sms] WHERE [Sms].[ToId] = @UserId ORDER BY [Sms].[SendTime] DESC, [Sms].[SmsId] DESC ) ORDER BY [Sms].[SendTime] DESC, [Sms].[SmsId] DESC";
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@UserId", SqlDbType.NVarChar, 20) };
            commandParameters[0].Value = userId;
            DataSet set = SqlHelper.ExecuteDataset(conn, CommandType.Text, commandText, commandParameters);
            set.Tables[0].TableName = "Sms";
            return set.Tables[0];
        }

        public void SmsCheck(SqlConnection conn, string userId, string ip, ref int newTotalNum, ref int onlineNum)
        {
            decimal num = new ConfigManager().AjaxInterval / 0xea60;
            string commandText = "IF NOT EXISTS(SELECT [UserId] FROM [dbo].[Users] WHERE [UserId] = @UserId AND [State] > 0) UPDATE [dbo].[Users] SET [State] = 1, [OnlineTime] =[OnlineTime] + " + num.ToString() + ", [LastPassTime] = GETDATE(), [LastIp] = @Ip WHERE [UserId] = @UserId ELSE UPDATE [dbo].[Users] SET [OnlineTime] =[OnlineTime] + " + num.ToString() + ", [LastPassTime] = GETDATE(), [LastIp] = @Ip WHERE [UserId] = @UserId SELECT @NewTotalNum = COUNT(*) FROM [dbo].[Sms] WHERE [ToId] = @UserId AND [Sms].[RemindFlag] = 1 AND [Sms].[SendTime] < GETDATE() SELECT @OnlineNum = COUNT(*) FROM [dbo].[Users] WHERE [State] > 0 AND [DeptId] <> -1";
            SqlParameter[] commandParameters = new SqlParameter[4];
            commandParameters[0] = new SqlParameter("@UserId", SqlDbType.NVarChar, 20);
            commandParameters[0].Value = userId;
            commandParameters[1] = new SqlParameter("@Ip", SqlDbType.NVarChar, 20);
            commandParameters[1].Value = ip;
            commandParameters[2] = new SqlParameter("@NewTotalNum", SqlDbType.Int);
            commandParameters[2].Direction = ParameterDirection.Output;
            commandParameters[3] = new SqlParameter("@OnlineNum", SqlDbType.Int);
            commandParameters[3].Direction = ParameterDirection.Output;
            SqlHelper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters);
            if (commandParameters[2].Value != DBNull.Value)
            {
                newTotalNum = Convert.ToInt32(commandParameters[2].Value);
            }
            if (commandParameters[3].Value != DBNull.Value)
            {
                onlineNum = Convert.ToInt32(commandParameters[3].Value);
            }
        }

        public DataTable SmsShow(SqlConnection conn, string userId, ref int newTotalNum)
        {
            string commandText = "SELECT @NewTotalNum = COUNT(*) FROM [dbo].[Sms] WHERE [ToId] = @UserId AND [RemindFlag] = 1 AND [SendTime] < GETDATE() SELECT TOP 1 [Sms].*, [Users].[UserName], [Department].[DeptName], [Users].[Avatar], [Sys_Code].[CodeName], [Sys_Code].[FuncCode] FROM [dbo].[Sms], [dbo].[Users], [dbo].[Department], [dbo].[Sys_Code] WHERE [Sms].[ToId] = @UserId AND [Sms].[FromId] = [Users].[UserId] AND [Users].[DeptId] = [Department].[DeptId] AND [Sms].[RemindFlag] = 1 AND [Sms].[SendTime] < GETDATE() AND CAST([Sms].[Type] AS nvarchar) = [Sys_Code].[CodeNo] AND [Sys_Code].[CodeFlag] = 'SMS_REMIND' ORDER BY [Sms].[SendTime] ASC, [Sms].[SmsId] ASC";
            SqlParameter[] commandParameters = new SqlParameter[2];
            commandParameters[0] = new SqlParameter("@UserId", SqlDbType.NVarChar, 20);
            commandParameters[0].Value = userId;
            commandParameters[1] = new SqlParameter("@NewTotalNum", SqlDbType.Int);
            commandParameters[1].Direction = ParameterDirection.Output;
            DataSet set = SqlHelper.ExecuteDataset(conn, CommandType.Text, commandText, commandParameters);
            if (commandParameters[1].Value != DBNull.Value)
            {
                newTotalNum = Convert.ToInt32(commandParameters[1].Value);
            }
            else
            {
                newTotalNum = 0;
            }
            set.Tables[0].TableName = "Sms";
            return set.Tables[0];
        }

        public enum DeleteType
        {
            Send,
            Reveive
        }

        public enum SmsType
        {
            Attend = 6,
            Calendar = 5,
            Diary = 13,
            Email = 2,
            Event = 0x10,
            Meeting = 8,
            Mobile = 10,
            NetMeeting = 3,
            News = 14,
            Notify = 1,
            Project = 0x12,
            Report = 15,
            Rms = 0x11,
            Sms = 0,
            Vehicle = 9,
            Vote = 11,
            WorkFlow = 7,
            WorkPlan = 12
        }
    }
}

